<template>
   <footer class="footer">
      <span class="todo-count"><strong>{{list.length}}</strong>剩余</span>
      <ul class="filters" @click="changeType">
        <li>
          <a :class="{selected:type==='all'}" @click.prevent="type='all'" href="#/">全部</a>
        </li>
        <li>
          <a :class="{selected:type==='active'}" @click.prevent="type='active'" href="#/active">进行中</a>
        </li>
        <li>
          <a :class="{selected:type==='completed'}" @click.prevent="type='completed'" href="#/completed">已完成</a>
        </li>
      </ul>
      <button class="clear-completed" v-show="clearIsShow" @click="$emit('clearTask')">清除已完成</button>
    </footer>
</template>
<script>
export default {
  name: 'TodoFooter',
  props:{
    list:{
      required:true,
      type:Array
    }
  },
  data() {
    return {
      type:'all'
    };
  },
  methods: {
    changeType(){
      this.$emit('changeType',this.type)
    }
  },
  computed:{
    clearIsShow(){
      return this.list.some(item=>item.isDone)
    }
  }
};
</script>

<style lang="scss" scoped>

</style>